import request from "@/utils/request";
import type { AttrListParams, AttrsList,SaveAttrApiParams } from "./modles/attrsModel";

enum Api {
  getAttrInfo = "/admin/product/attrInfoList",
  saveAttr = "/admin/product/saveAttrInfo",
  delAttrList ="/admin/product/deleteAttr"
}

// 获取数据列表
// /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
export const getAttrInfoListApi = ({
  category1Id,
  category2Id,
  categoty3Id,
}: AttrListParams) => {
  return request.get<any, AttrsList>(
    `${Api.getAttrInfo}/${category1Id}/${category2Id}/${categoty3Id}`
  );
};

// 添加属性// 更新
export const saveAtterApi = (data: SaveAttrApiParams) => {
  return request.post<any, null>(Api.saveAttr, data);
};

// attrList 属性列表 点击删除

export const delAttrListApi = (attrId:number) =>{
  return request.delete<any,null>(`${Api.delAttrList}/${attrId}`);
}